package com.wujilee.wujileejuc.aqs;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.LockSupport;

/**
 * @author liwuji
 * @date 2024/7/8
 * @desc
 **/
public class LockSupportTest {
    private static  final Map<String,String > cache = new ConcurrentHashMap<>();
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            synchronized (LockSupportTest.class){
                System.out.println(Thread.currentThread().getName() +"进入等待");
                LockSupport.park();
                System.out.println(Thread.currentThread().getName() +"继续执行");
            }
        },"t1");

        Thread thread2 = new Thread(() -> {
            synchronized (LockSupportTest.class){
                System.out.println(Thread.currentThread().getName() +"执行");
            }
        },"t2");
        thread.start();
        thread2.start();
        LockSupport.unpark(thread);
        Thread.sleep(100L);

        String put = cache.put("hello", "hello");

    }
}
